<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增页</title>
    <link rel="stylesheet" href="./static/css/index.css">
</head>

<body>

    <div>
        <div>
            <h1>新增用户</h1>
        </div>
        <div>
            <table>
                <tr>
                    <th>
                        姓名: <input type="text" id="uname" placeholder="请输入姓名">
                    </th>
                    <th>
                        年龄: <input type="text" id="uage" placeholder="请输入年龄">
                    </th>
                </tr>
                <tr>
                    <td>
                        <input type="button" value="确认" onclick="saveU()">
                        <input type="button" value="返回" onclick="cancelU()">
                    </td>
                </tr>
            </table>
        </div>
    </div>

    <script src="./static/js/axios.min.js"></script>
    <script>
        function saveU() {
            let uname = document.querySelector("#uname").value
            let uage = document.querySelector("#uage").value
            if (confirm("确认添加吗???")) {
                axios.post("http://localhost:3000/user", { uname, uage }).then(() => {
                    location.href = './index.html'
                })
            }

        }

        function cancelU() {
            location.href = './index.html'
        }
    </script>
</body>

</html>